﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Web.UI;

[assembly: System.Web.UI.WebResource("MyControl.DualList.Clear.png", "image/png")] 

namespace MyControl
{
    public class DualList : CompositeControl
    {
        protected override HtmlTextWriterTag TagKey
        {
            get
            {
                return HtmlTextWriterTag.Div;   
            }
        }

        Panel box1 = new Panel();
        TextBox box1Filter = new TextBox();
        ImageButton box1Clear = new ImageButton();
        ListBox box1View = new ListBox();
        ListBox box1Storage = new ListBox();

        Panel box2 = new Panel();
        TextBox box2Filter = new TextBox();
        ImageButton box2Clear = new ImageButton();
        ListBox box2View = new ListBox();
        ListBox box2Storage = new ListBox();

        HtmlGenericControl ul = new HtmlGenericControl("ul");
        ImageButton to2 = new ImageButton();
        ImageButton allTo2 = new ImageButton();
        ImageButton allTo1 = new ImageButton();
        ImageButton to1 = new ImageButton();

        protected override void CreateChildControls()
        {
            CssClass = "dual-listbox clearfix";

            box1.CssClass = "select-wrapper";
            box1.Controls.Add(box1Filter);
            box1Clear.CssClass = "clear-button";
            box1Clear.ImageUrl = Page.ClientScript.GetWebResourceUrl(GetType(), "MyControl.DualList.Clear.png");
            
            //ib.ImageUrl = ClientScriptManager.GetWebResourceUrl(this.GetType(), "JUtil.Web.WebControls.TextBox.DateEdit.Calendar.png");
            //return CurPage.ClientScript.GetWebResourceUrl(type, webResource);
            box1.Controls.Add(box1Clear);
            box1.Controls.Add(box1View);
            box1.Controls.Add(box1Storage);

            HtmlGenericControl li = null;

            li = new HtmlGenericControl("li");
            li.Controls.Add(to2);
            ul.Controls.Add(li);

            li = new HtmlGenericControl("li");
            li.Controls.Add(allTo2);
            ul.Controls.Add(li);

            li = new HtmlGenericControl("li");
            li.Controls.Add(allTo1);
            ul.Controls.Add(li);

            li = new HtmlGenericControl("li");
            li.Controls.Add(to1);
            ul.Controls.Add(li);

            box2.CssClass = "select-wrapper";
            box2.Controls.Add(box2Filter);
            box2Clear.CssClass = "clear-button";
            box2.Controls.Add(box2Clear);
            box2.Controls.Add(box2View);
            box2.Controls.Add(box2Storage);

            Controls.Add(box1);
            Controls.Add(ul);
            Controls.Add(box2);
        }
    } // end of DualList
}
